home *** CD-ROM | disk | FTP | other *** search
/ i·cite - visualizing sources / iCite.iso / data / sp_website1.dir / 00003_Script_Flash Cursor < prev    next >
Text File  |  2006-06-30  |  8KB  |  255 lines

  1. --******************************************************************************
  2. -- SUMMARY
  3. --******************************************************************************
  4. --  Description: This behavior allows Director to accept a Flash movie's cursor
  5. --    setting. Additionally setting the sprite's cursor property may cause
  6. --    unexpected cursor results. For best results use either the sprite cursor
  7. --    property OR this Flash Cursor behavior.
  8. --
  9. --  Usage:
  10. -- 
  11. --    1) Drop this behavior onto a Flash sprite.
  12. --
  13. --  History:
  14. --    23 Sep 2002. Kraig Mentor. Initial file submission.
  15. --
  16. --
  17. --
  18. --******************************************************************************
  19. -- AUTHOR DEFINED PROPERTIES
  20. --******************************************************************************
  21. -- None.
  22.  
  23.  
  24.  
  25. --******************************************************************************
  26. -- GENERAL PROPERTIES
  27. --******************************************************************************
  28. property pActive ------- Boolean. True if the mouse is within the sprite.
  29. property pFrameCursor -- Integer. The current frame cursor.
  30. property pInitialized -- Boolean. True once the initialization handler has run.
  31. property pMember ------- Member. The member of this sprite.
  32. property pPrevCursor --- Integer. The previous Flash cursor value.
  33. property pSprite ------- Sprite. This sprite.
  34. property pStateOK ------ Boolean. True when the member's initial state
  35. --                       is stable.
  36.  
  37.  
  38.  
  39. --******************************************************************************
  40. -- SPRITE HANDLERS
  41. --******************************************************************************
  42. on beginSprite(me)
  43.   
  44.   pSprite = sprite(me.spriteNum)
  45.   pMember = pSprite.member
  46.   pStateOK = me.isStateOK(pMember, pSprite)   
  47.   
  48.   if pStateOK then
  49.     pInitialized = me.initialize()
  50.   else
  51.     pInitialized = FALSE 
  52.   end if 
  53.   
  54. end
  55.  
  56.  
  57. --------------------------------------------------------------------------------
  58. on endSprite(me)
  59.   
  60.   me.restoreCursor()
  61.   
  62. end endSprite
  63.  
  64.  
  65. --******************************************************************************
  66. -- EVENT HANDLERS
  67. --******************************************************************************
  68. on mouseEnter(me)
  69.   
  70.   pActive = TRUE
  71.   
  72. end mouseEnter
  73.  
  74.  
  75. --------------------------------------------------------------------------------
  76. on mouseLeave(me)
  77.   
  78.   pActive = FALSE
  79.   me.restoreCursor()
  80.   
  81. end mouseLeave
  82.  
  83.  
  84. --------------------------------------------------------------------------------
  85. on enterFrame(me)
  86.   
  87.   if pStateOK then    
  88.     if pInitialized then
  89.       if pActive then
  90.         me.setCursor()
  91.       end if
  92.     else
  93.       pInitialized = me.initialize()      
  94.     end if     
  95.   else   
  96.     pStateOK = me.isStateOK(pMember, pSprite)  
  97.   end if  
  98.   
  99. end enterFrame
  100.  
  101.  
  102.  
  103.  
  104. --******************************************************************************
  105. -- CUSTOM HANDLERS
  106. --******************************************************************************
  107. --PURPOSE: Performs initialze set up of the sprite.
  108. --ACCEPTS: 'me' as an instance of this script.
  109. --RETURNS: True.
  110. --EFFECTS: 'pInitialized' gets set.
  111. --------------------------------------------------------------------------------
  112. on initialize(me) 
  113.   
  114.   tInitialized = TRUE
  115.   pActive = FALSE
  116.   
  117.   pFrameCursor = sprite(0).cursor
  118.   
  119.   if pSprite.cursor <> pFrameCursor then
  120.     pPrevCursor = pSprite.cursor
  121.   else
  122.     pPrevCursor = pFrameCursor
  123.   end if
  124.   
  125.   return( tInitialized )
  126.   
  127. end initialize
  128.  
  129.  
  130. --------------------------------------------------------------------------------
  131. --PURPOSE: Verifies that conditions are acceptable for implementation.
  132. --ACCEPTS: 'me' as an instance of this script.
  133. --RETURNS: True if the member has the minimal download reached.
  134. --------------------------------------------------------------------------------
  135. on isStateOK(me, aMember, aSprite)  
  136.   
  137.   tStateOK = TRUE
  138.   return(tStateOK)   
  139.   
  140. end isStateOK 
  141.  
  142.  
  143. --------------------------------------------------------------------------------
  144. --PURPOSE: Provides a behavior description in the behavior inspector.
  145. --ACCEPTS: 'me' as a reference to a script member.
  146. --RETURNS: 'tString' as a string.
  147. --------------------------------------------------------------------------------
  148. on restoreCursor(me)
  149.   
  150.   if pPrevCursor <> pFrameCursor then
  151.     cursor( pFrameCursor )
  152.     pPrevCursor = pFrameCursor
  153.   end if
  154.   
  155. end
  156.  
  157.  
  158. --------------------------------------------------------------------------------
  159. on setCursor(me)
  160.   
  161.   tFlashCursor = pSprite.getflashProperty("", #cursor)
  162.   --  Return values...
  163.   --  0: No cursor
  164.   --  1: Arrow
  165.   --  2: Hand with finger
  166.   --  3: Hand
  167.   --  4: I Beam
  168.   
  169.   case tFlashCursor of
  170.     0: tDirectorCursor = 200
  171.     1: tDirectorCursor =  -1
  172.     2: tDirectorCursor = 280
  173.     3: tDirectorCursor = 260 
  174.     4: tDirectorCursor =   1
  175.     otherwise:
  176.       tDirectorCursor = pSprite.cursor
  177.   end case
  178.   
  179.   if pPrevCursor <> tDirectorCursor then
  180.     
  181.     cursor( tDirectorCursor )
  182.     pPrevCursor = tDirectorCursor
  183.     
  184.   end if
  185.   
  186. end setCursor
  187.  
  188.  
  189.  
  190.  
  191. --******************************************************************************
  192. -- PREDEFINED HANDLERS
  193. --******************************************************************************
  194. --PURPOSE: Determines whether the behavior can be dropped onto a sprite in the 
  195. --         score.
  196. --ACCEPTS: 'me' as a reference to a script member.
  197. --         'aSpriteType' as a symbol. It indicates the type of sprite attempting 
  198. --         to be dropped on to.
  199. --         'aSpriteNum' as an integer. Indicates the channel of the sprite being 
  200. --         dropped on to.
  201. --RETURNS: True if the behavior is allowed to be dropped on the sprite or score, 
  202. --         false otherwise.
  203. --------------------------------------------------------------------------------
  204. on isOKtoAttach(me, aSpriteType, aSpriteNum)
  205.   
  206.   if aSpriteType = #graphic then
  207.     if sprite(aSpriteNum).member.type = #flash then
  208.       return(TRUE) 
  209.     end if
  210.   end if   
  211.   
  212.   return(FALSE)  
  213.   
  214. end isOKtoAttach
  215.  
  216.  
  217. --------------------------------------------------------------------------------
  218. --PURPOSE: Provides a tooltip in the behavior library palette.
  219. --ACCEPTS: 'me' as a reference to a script member.
  220. --RETURNS: 'tString' as a string.
  221. --------------------------------------------------------------------------------
  222. on getBehaviorToolTip(me)
  223.   
  224.   tString1 = "Allows Director's cursor to obey the Flash movie's cursor setting." & RETURN & RETURN & \
  225.     "PERMITTED SPRITE TYPES: Flash." & RETURN & RETURN & \
  226.     "USAGE: Apply to a Flash sprite. " & \
  227.     "" & RETURN & RETURN & \
  228.     "DEPENDENCIES: None."
  229.   return(tString1)   
  230.   
  231. end getBehaviorToolTip
  232.  
  233.  
  234. --------------------------------------------------------------------------------
  235. --PURPOSE: Provides a behavior description in the behavior inspector.
  236. --ACCEPTS: 'me' as a reference to a script member.
  237. --RETURNS: 'tString' as a string.
  238. --------------------------------------------------------------------------------
  239. on getBehaviorDescription(me)
  240.   
  241.   tString1 = "FLASH CURSOR" & RETURN & RETURN & \
  242.     "Drop the behavior onto a Flash sprite to allow Director to maintain the Flash movie's cursor settings." & RETURN & RETURN & \
  243.     "Apply this behavior to a Flash sprite." & RETURN & RETURN & \
  244.     "PERMITTED MEMBER TYPES:" & RETURN & \
  245.     "Flash" & RETURN & RETURN & \
  246.     "PARAMETERS:" & RETURN & \
  247.     "None."
  248.   return(tString1)
  249.   
  250. end getBehaviorDescription
  251.  
  252.  
  253. --******************************************************************************
  254. --******************************************************************************
  255. --******************************************************************************